<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-sys__dict">
      <el-form
        :inline="true"
        :model="dataForm"
        @keyup.enter.native="getDataList()"
      >
        <el-form-item>
          <el-date-picker
            v-model="dataForm.playDate"
            value-format="yyyy-MM-dd"
            type="date"
            placeholder="游玩日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-input
            v-model="dataForm.goodsName"
            placeholder="商品名称"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button @click="getDataList()">{{ $t("query") }}</el-button>
        </el-form-item>
        <!-- <el-form-item>
          <el-button type="primary" @click="addOrUpdateHandle()">{{
            $t("add")
          }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="danger" @click="deleteHandle(id)">{{
            $t("deleteBatch")
          }}</el-button>
        </el-form-item> -->
      </el-form>
      <el-table
        v-loading="dataListLoading"
        :data="dataList"
        border
        @selection-change="dataListSelectionChangeHandle"
        @sort-change="dataListSortChangeHandle"
        style="width: 100%"
      >
        <el-table-column
          type="selection"
          header-align="center"
          align="center"
          width="50"
        ></el-table-column>
        <el-table-column
          prop="goodsName"
          label="商品名称"
          :show-overflow-tooltip="true"
          header-align="center"
          min-width="150"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="playDate"
          label="游玩日期"
          header-align="center"
          min-width="120"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="playTime"
          label="游玩时间"
          header-align="center"
          min-width="120"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="avePrice"
          label="人均价格"
          header-align="center"
          min-width="150"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="residueClusteringNum"
          label="剩余成团人数"
          min-width="150"
          header-align="center"
          align="center"
        >
        </el-table-column>
        <el-table-column
          :label="$t('handle')"
          fixed="right"
          header-align="center"
          align="center"
          min-width="200"
        >
          <template slot-scope="scope">
            <el-button
              type="text"
              size="small"
              @click="lookDetail(scope.row.id)"
              >查看</el-button
            >
            <!-- <el-button
              v-if="scope.row.goodsType == 2"
              type="text"
              size="small"
              @click="edit(scope.row.id, 3)"
              >发起拼船</el-button
            > -->
            <el-button
              v-if="scope.row.goodsType == 2"
              type="text"
              size="small"
              @click="edit(scope.row.id, 1)"
              >发布特价</el-button
            >
            <el-button
              type="text"
              size="small"
              @click="deleteHandle(scope.row.id)"
              >{{ $t("delete") }}</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="page"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="limit"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle"
      >
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <!-- 详情 -->
      <detail ref="lookDetail" v-if="lookDetailVisible"> </detail>
    </div>
  </el-card>
</template>

<script>
var that;
import mixinViewModule from "@/mixins/view-module";
import detail from "./detail";
export default {
  mixins: [mixinViewModule],
  filters: {
    delStatus(val) {
      if (val) {
        let d = that.goodsType.filter((item) => item.value == val);
        if (d.length != 0) {
          return d[0].label;
        }
      }
    },
  },
  data() {
    return {
      mixinViewModuleOptions: {
        getDataListURL: "/scenic/goods/page",
        getDataListIsPage: true,
        deleteURL: "/scenic/goods",
        deleteIsBatch: true,
      },
      type: "",
      goodsType: [
        {
          label: "特价",
          value: 1,
        },
        {
          label: "包船",
          value: 2,
        },
        {
          label: "拼船",
          value: 3,
        },
      ],
      dataForm: {
        merchantId:
          this.$store.state.user.MerchantId ||
          localStorage.getItem("MerchantId"),
        goodsType: 3,
          playDate: "",
        status: "",
        goodsName: "",
        // name: '',
        // merchantType: '',
        // status: '',
        // activity: '',
        // islandId: '',
        // linkName: '',
        // phone: '',
      },
    };
  },
  components: {
    detail,
  },
  created() {
    that = this;
  },
  methods: {},
};
</script>
